
import 'package:basic_common/common_exports.dart';
import 'package:basic_modle/dr_profile_data.dart';
import 'package:basic_modle/single_user_info.dart';

class ReviewProController extends GetxController {
  List titles = [
    {"title": "实名认证", "status": "已完成", "state": "0"},
    {"title": "医生身份认证", "status": "已完成", "state": "0"},
    {"title": "资质审核", "status": "审核中", "state": "1"}
  ];
  int currentStep = 1;
  final statusStr = '未认证'.obs;
  final subTitle = '平台将在1~2个工作日内为您审核通过'.obs;
  @override
  void onInit() {
    // TODO: implement onInit
    getDrProfile();
    super.onInit();
  }

  /// 获取医生信息
  getDrProfile() async {
    HttpData res = await ApiService().drProfile(data: {
      "scene": "get-by-token",
      "sceneDesc": "",
      "searchKey": "Token",
      "searchValue": ""
    });
    if (res.code == 1) {
      if (res.data['doctor'] == null || res.data['identity'] == null) {
        getSIngleUserInfo();
      } else {
        DrProfileData drData = DrProfileData.fromJson(res.data);
        DoctorData? doctorInfo = drData.doctor;

            getDrInfo(doctorInfo!.verifiedFlag!);

        // verifiedFlag 0 未认证 1 已认证
        // 医生信息为null 代表还未进行实名认证 身份认证 资质认证
       
      }
    }
  }

  /// 获取单个用户信息
  getSIngleUserInfo() async {
    HttpData res = await ApiService().getUserInfoByToken(data: {
      "scene": "get-by-token",
      "sceneDesc": "登录后获取用户个人信息",
      "searchKey": "Token",
      "searchValue": "0"
    });
    if (res.code == 1) {
      SingleUserInfo userInfo = SingleUserInfo.fromJson(res.data);
      String uId = userInfo.userId!;
      String phone = userInfo.phone!;
      if (uId.isEmpty || phone.isEmpty) {
        return ToastUtils.toast("医生ID不能为空");
      }
      // Get.offAllNamed(AppRoutes.realname,
      //     arguments: {"phone": phone, "id": uId});
    }
  }

  /// 获取医生信息
  getDrInfo(String flag) {
      if (flag == '1') {
        statusStr.value = "已通过";
        subTitle.value = "您的申请已通过";
      } else if (flag == '4') {
        statusStr.value = "被拒绝";
        subTitle.value = "您的申请被拒绝";
      } else if (flag == '2') {
        statusStr.value = "审核中";
        subTitle.value = "平台将在1~2个工作日内为您审核通过";
      }
  
  }
}
